<template>
  <div class="treePromiss">

    <a-directory-tree
      :tree-data="treeData"
      @select="onSelect"
      :default-expand-all="expandFlag"
      :default-selected-keys="defaultSelectKeys"
      v-if="treeData.length>0"
      @expand="onExpand"
      :show-icon="true"
    ></a-directory-tree>
    <!-- <a-tree :tree-data="treeData" :replaceFields="replaceFields" show-icon>
      <svg-icon slot="smile" style="font-size:23px;vertical-align: -0.33em;" icon-class="logo"></svg-icon>
    </a-tree> -->
  </div>
</template>

<script>
export default {
  name: 'treePromiss',
  
  props:['defaultSelectKeys','treeData','expandFlag'],
  data() {
    return {}
  },
  methods: {

     onExpand(expandedKeys) {
      this.expandedKeys = expandedKeys
      this.autoExpandParent = false
    },
    onSelect(selectedKeys, info) {
      //   console.log(selectedKeys, info)

      this.$emit('treeKey', selectedKeys[0])
    },
    // onLoadData(treeNode) {
    //   return new Promise((resolve) => {
    //     if (treeNode.dataRef.children) {
    //       resolve()
    //       return
    //     }
    //     setTimeout(() => {
    //       treeNode.dataRef.children = [
    //         {
    //           title: 'Child Node',
    //           key: `${treeNode.eventKey}-0`,
    //           slots: {
    //             icon: 'smile'
    //           }
    //         },
    //         {
    //           title: 'Child Node',
    //           key: `${treeNode.eventKey}-1`,
    //           slots: {
    //             icon: 'smile'
    //           }
    //         }
    //       ]
    //       this.treeData = [...this.treeData]
    //       resolve()
    //     }, 1000)
    //   })
    // }
  }
}
</script>

<style lang="less" scoped></style>
